<?php ob_start(); session_start();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Hồ sơ cá nhân</title>
<link href="../Twitter_Bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="../CSS/css_admin.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="../Twitter_Bootstrap/css/datepicker.css"/>
<link rel="stylesheet" type="text/css" href="../CSS/validationEngine.jquery.css"/>
<script type="text/javascript" src="../Scripts/jquery.min.js"></script> 
<script type="text/javascript" src="../Twitter_Bootstrap/js/jquery.js"></script>
<script type="text/javascript" src="../Twitter_Bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../Twitter_Bootstrap/js/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="../Scripts/jquery.validationEngine.js"></script>
<script type="text/javascript" src="../Scripts/jquery.validationEngine-vi.js"></script>
<script type="text/javascript" src="../Scripts/jquery.form.js"></script> 

	<script>
		$(function(){
				$("#formProfile").validationEngine();
		});//close jquery
		
	</script>

<style>


.preview
{
width:100px;
border:solid 1px #dedede;
padding:10px;
}
#preview
{
color:#cc0000;
font-size:12px
}

</style>
</head>

<body>
<div class="container" id="Container">
  
  <!--Menu top -->
  <div id="menu">
   <?php
   include("MainMenu.php");
   include("../Connections/connect_admin.php");
   if(!isset($_SESSION["username"]))
   {
	   header('location:Login.php');
   }
   $imgUser="../Images/Img_User/";
   $user=$_SESSION["username"];
   $query="select * from user where UserName='$user'";
   $result=mysql_query($query);
   $row=mysql_fetch_assoc($result);  
   ?>
    </div>
  </div>
  <div id="divContain">
  <div class="divTitle"><span class="titlePage" >Hồ sơ cá nhân</span></div>
    <!--Content -->
    <br />
     <?php
	if(isset($_GET["e"]))
	{
		$error=intval($_GET["e"]);
		switch($error)
		{
			case 0:
	?>
    <div class="alert alert-success">
    	    <a class="close" data-dismiss="alert" href="#">&times;</a>
            <strong>Cập nhật thông tin THÀNH CÔNG</strong>
    </div>
    <?php
			break;
			case 1:
	?>
     <div class="alert alert-error">
    	    <a class="close" data-dismiss="alert" href="#">&times;</a>
            <strong>Cập nhật thông tin THẤT BẠI</strong>
    </div>
     <?php
	 		break;
		}
	}
	?>
     <script type="text/javascript" >
 			$(document).ready(function() { 
			
						$('#photoimg').live('change', function()			{ 
								   $("#preview").html('');
							$("#preview").html('<img src="../Images/Icons/ajax-loader-big.gif" alt="Uploading...."/>');
						
						$("#imageform").ajaxForm({target: '#preview'}).submit();});
					});
			function ToggleUpload()
			{
				$('#imageform').toggle();
				$('#changeImage').toggle();
			}
			</script>
            
        <table cellpadding="0" cellspacing="0" border="0" width="50%">
        <tr>
        	<td style="width:35%">
        <div id='preview'>
					<img src="<?php echo $imgUser.$row["Image"]; ?>" alt="avatar" class="preview" />
		</div>
         	</td>
            <td>
            <input type="button" class="btn" value="Thay đổi Avatar" id="changeImage" onclick="ToggleUpload();" />
             <form id="imageform" name="imageform" method="post" enctype="multipart/form-data" action="ajaximage.php" class="hide">
            	<input type="file" name="photoimg" id="photoimg" /><br />
                <input type="button" value="Đóng lại" class="btn" onclick="ToggleUpload();" />
            </form>
            </td>
            </tr>
            </table>
            
    <form action="process/Account_add.php" method="post" id="formProfile" style="padding-top:20px">
   <input type="hidden" value="updateUser" name="task" />
 
        <table cellpadding="0" cellspacing="0" border="0">
        	<tr >
                <td style="width:25%">Tên đăng nhập</td>
                <td><input name="username" type="text" id="txtUserName" readonly="readonly"  value="<?php echo $user; ?>" /></td>
          	</tr>
            
          <tr>
            <td>Họ tên:</td>
            <td><input type="text" name="fullname" id="txtFullName" class="validate[required]" value="<?php echo $row["FullName"]; ?>" /></td>
          </tr>
          <tr>
            <td>Ngày sinh:</td>
            <td><input type="text" name="birthdate" id="txtBirthDay" class="datepicker validate[required]" value="<?php 
			$sqldate= strtotime($row["BirthDay"]);
			$date=date('d/m/Y',$sqldate);
			echo $date; ?>" data-date-format="dd/mm/yyyy" /></td>
            <script type="text/javascript">
			$(document).ready(function(){
									   $('#txtBirthDay').datepicker();
									   });
			</script>
          </tr>
          <tr>
            <td>Giới tính</td>
            <td><label class="radio inline">
              <input type="radio" name="sex" id="rbtMale" value="male" <?php if($row["Sex"]>0) echo 'checked="checked"'; ?> />
              Nam </label>
              &nbsp;
              <label class="radio inline">
                <input type="radio" name="sex" id="rbtFeMale" value="female" <?php if($row["Sex"]<1) echo 'checked="checked"'; ?> />
                Nữ </label></td>
          </tr>
          <tr>
            <td>Mô tả:</td>
            <td><textarea type="text" name="description" id="txtDescription" class="span6" rows="3" >
            <?php echo $row["Description"]; ?>
            	</textarea>
            </td>
          </tr>
          <tr>
            <td>Địa chỉ</td>
            <td><input type="text" name="address" id="txtAddress"  class="span6" value="<?php echo $row["Address"]; ?>"/>
            </td>
          </tr>
          <tr>
            <td>Email:</td>
            <td><input type="text" name="email" id="txtEmail" class="validate[custom[email]]" value="<?php echo $row["Email"]; ?>" /></td>
          </tr>
          <tr>
            <td>ĐT cố định:</td>
            <td><input type="text" name="phone" id="txtPhone" value="<?php echo $row["MobileNumber"]; ?>" /></td>
          </tr>
          <tr>
            <td>ĐT di động:</td>
            <td><input type="text" name="mobile" id="txtMobile" value="<?php echo $row["PhoneNumber"]; ?>" /></td>
          </tr>
          <tr>
          <td></td>
            <td><input name="btnUpdate" type="submit" id="btnUpdate" value="C&#7853;p nh&#7853;t" class="btn btn-primary span2" />
              <a href="MyProfile.php" class="btn span2">Hủy bỏ</a></td>
          </tr>
        </table>   
     </form>
    <!--footer -->
  </div>
  <div id="footer">
   <?php
   include("Footer.php");
   ?>
  </div>
</div>

     
</body>
</html>
